package com.lee.dutylower.activity;

import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.lee.dutylower.BaseActivity;
import com.lee.dutylower.R;
import com.lee.dutylower.utils.SharedPreferencesUtils;
import com.lee.dutylower.view.wiget.FlashSettingView;

public class FlashActivity extends BaseActivity {
    private TextView tvLeft;
    private TextView tvRight;
    private String leftContent;
    private String rightContent;
    private int tvSize;
    private int tvColor;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flash);
        tvLeft = (TextView) findViewById(R.id.tv_left);
        tvRight = (TextView) findViewById(R.id.tv_right);
        updateFlash();
    }

    public void setting(View view) {
        AlertDialog dialog = new AlertDialog.Builder(this)
                .setTitle("展示页设置")
                .setCancelable(false)
                .create();
        FlashSettingView flashSettingView = new FlashSettingView(dialog,this,leftContent,rightContent,tvSize,tvColor);

        dialog.setView(flashSettingView);
        dialog.show();
    }

    public void toMain(View view) {
        startActivity(new Intent(this,MainActivity.class));
        finish();
    }

    public void updateFlash(){
        leftContent = (String) SharedPreferencesUtils.getParam(this, "tv-content-left", "不怕苦累不怕冷");
        rightContent = (String) SharedPreferencesUtils.getParam(this, "tv-content-right", "永夺红旗争先锋");
        tvSize = (int) SharedPreferencesUtils.getParam(this, "tv-size", 18);
        tvColor = (int) SharedPreferencesUtils.getParam(this, "tv-color", 0xFF001C53);

        tvLeft.setText(leftContent);
        tvLeft.setTextColor(tvColor);
        tvLeft.setTextSize(tvSize);

        tvRight.setText(rightContent);
        tvRight.setTextColor(tvColor);
        tvRight.setTextSize(tvSize);
    }
}
